package com.itheima.idea;

import java.util.Scanner;

public class HelloWorld {
    //psvm:快速生成main方法
    public static void main(String[] args) {
        /*//sout:快速生成输出语句
        System.out.println("Helloworld");
        int[] array = new int[3];
        System.out.println(array);//数组的内存地址
        //取值索引
        System.out.println(array[0]);
        System.out.println(array[1]);
        System.out.println(array[2]);
        //赋值
        array[0] = 11;
        array[1] = 22;
        array[2] = 33;
        System.out.println(array[0]);
        System.out.println(array[1]);
        System.out.println(array[2]);
        int[] arr = array;
        arr[0] = 55;
        System.out.println(array[0]);
        System.out.println(arr[0]);
        //静态初始化数组
        int[] arr1 = new int[]{11, 12, 13, 14};
        System.out.println(arr1[0]);
        int[] arr2;
        arr2 = new int[]{13, 14, 15};
        //数组的遍历
        for (int i = 0; i < arr2.length; i++) {
            System.out.println(arr2[i]);

        }
        //数组取最大值
        int max = arr2[0];//参照物一般都取数组的第一个元素
        for (int i = 0; i < arr2.length; i++) {
            if (arr2[i] > max) {
                max = arr2[i];
            }

        }
        System.out.println("最大值:" + max);*/



        /*Scanner sc = new Scanner(System.in);
        int[] arr = new int[5];
        for (int i = 0; i < arr.length; i++) {
            System.out.println("请输入第" + (i + 1) + "个整数");
            int temp = sc.nextInt();
            if (temp >= 50 && temp <= 100) {
                arr[i] = temp;
            } else {

                System.out.println("您输入的数据要在50-100");
                i--;//循环回退(控制i可以控制循环的次数)
            }

        }*/
        int[] arr = new int[]{4, 3, 5, 8, 7, 8, 8};
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入您要查找的数据:");
        int num = sc.nextInt();
        int count =0;
        int[] inarr = new int[7];
        inarr[0]=-1;
        for (int i = 0; i < arr.length; i++) {
            if (num == arr[i]) {
               inarr[count] =i;
               count++;

                }
                for(int j=0;j<count;j++)
                    System.out.println("全部索引为:"+inarr[j]);
            }


            }


}
